//
//  HandleNetProduct.m
//  FinancialProduct
//
//  Created by Stella on 2017/9/1.
//  Copyright © 2017年 maq. All rights reserved.
//
#import "NetworkConfig.h"
#import "SVProgressHUD.h"
#import "NSDictionary+NN.h"
#import "HandleNetProduct.h"
#import "UserModel.h"
#import "TKAlertCenter.h"

@implementation HandleNetProduct

#pragma mark -获取首页热卖产品列表
+ (void)getHotListforPageNo:(int)pageNo Success:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"Page":@(pageNo),@"AAAMethodName":@"HotProduct",@"PageSize":@"3"};
    NSLog(@"获取首页热卖产品列表请求参数：%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取首页热卖产品列表： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"] isKindOfClass:[NSArray class]]) {
                success(dataA);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}


#pragma mark -获取资产明细列表
+ (void)getInvestAssetListforParams:(NSDictionary *)params Success:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
//    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    //NSLog(@"params==： %@",[NSDictionary logDic:params]);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
//        [SVProgressHUD dismiss];
        NSLog(@"data==： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue]==0) {
            
            
            if ([data[@"data"] isKindOfClass:[NSArray class]]) {
                success(dataA);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];

        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}
#pragma mark -获取信息披露下的产品报告列表
+ (void)getReportListSuccess:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    UserModel *model=[UserModel getUser];
    int mid=[model.CustomerID intValue];
    NSDictionary *params=@{@"AAAMethodName":@"InfodisclosureReportSelect",@"CustomerID":@(mid)};
    //NSLog(@"获取信息披露下的产品公告、产品报告列表请求参数：%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        //NSLog(@"获取信息披露下的产品公告、产品报告列表： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"] isKindOfClass:[NSArray class]]) {
                success(dataA);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);

        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}
#pragma mark -获取交易明细列表
+ (void)getListforParams:(NSDictionary *)params Success:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", @"text/json", @"text/plain", @"text/javascript", @"text/xml", @"image/*",@"text/encode", nil];
    NSLog(@"请求参数%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
       [SVProgressHUD dismiss];
        NSLog(@"数据返回： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"] isKindOfClass:[NSArray class]] ) {
                success(dataA);
            }else{
                failure(HTTP_REQUEST_FAILURE);
//                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
//            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
         [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -获取商品详情
+ (void)getDetailForParams:(NSDictionary *)params Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
//    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSLog(@"请求参数%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
//        [SVProgressHUD dismiss];
        NSLog(@"数据返回： %@",[NSDictionary logDic:data]);
        NSDictionary *dataA = nil;
        NSArray *dataB = nil;
        if ([params[@"AAAMethodName"] isEqualToString:@"ProductDetail"]) {
            dataA = data[@"data"];
        }
        else {
            dataB=data[@"data"];
        }

        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count] >0) {
                if ([params[@"AAAMethodName"] isEqualToString:@"ProductDetail"]) {
                    success(dataA);
                }
                else {
                    success(dataB[0]);
                }
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];

        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -获取存续资产
+ (void)getCAAssetsforCustomerID:(int)customerID Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"CustomerID":@(customerID),@"AAAMethodName":@"CXAssets"};
    NSLog(@"获取存续资产params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取存续资产： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
         [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}
#pragma mark -预约理财师
+ (void)MakeFAWithParams:(NSDictionary *)params WithAnimated:(BOOL)animated Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    if (animated) {
        [HandleNetProduct show];
    }
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        //NSLog(@"预约理财师： %@",[NSDictionary logDic:data]);
       
        if ([data[@"state"] intValue]==0) {
            
            success(data);
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);

        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -检查更新
+ (void)CheckAPPVersonSuccess:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
//    [HandleNetProduct show];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
     NSDictionary *params=@{@"AAAMethodName":@"SelectAPPEditionURL",@"Device":@"IOS"};
    NSLog(@"检查更新： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        NSLog(@"检查更新： %@",[NSDictionary logDic:data]);
//        [SVProgressHUD dismiss];
     
        if ([data[@"state"] intValue]==0) {
            /***
             
             ***/
            
            success(data);
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}


#pragma mark -更新版本
//AAAMethodName=UpdateAPPEdition&Device=IOS&APPEdition=2.3.7
+ (void)updateAPPVersonSuccess:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"UpdateAPPEditionURL",@"Device":@"IOS",@"APPEdition":version};
    NSLog(@"更新版本params---%@",[NSDictionary logDic:params]);
    //AAAMethodName=UpdateAPPEditionURL&APPEdition=1.0&Device=IOS
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        NSLog(@"更新版本： %@",[NSDictionary logDic:data]);
        [SVProgressHUD dismiss];
        
        if ([data[@"state"] intValue]==0) {
            /***
             
             ***/
            
            success(data);
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}


#pragma mark -温馨提示
+ (void)GetReminderUrlWith:(NSString *)typeName userId:(NSString *)mid Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
   
    NSDictionary *params=@{@"AAAMethodName":@"Reminder",@"CustomerID":mid,@"ProductTypeLevel":typeName};
    [HandleNetProduct postUrl:API_HOST1 parameters:params Success:^(NSDictionary *data) {
        if ([data[@"data"] isKindOfClass:[NSArray class]]&&[data[@"data"] count]>0) {
            success([data[@"data"] firstObject]);
        }else{
            failure(HTTP_LOADDATE_FAILURE);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
        }
        
        
    } Failure:^(NSString *errorInfo) {
        failure(HTTP_REQUEST_FAILURE);
    }];
}

+ (void)postUrl:(NSString *)url parameters:(NSDictionary *)param Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
     [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        
        if ([data[@"state"] intValue]==0) {
            success(data);
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -获取签约列表
+ (void)getSigningListforCustomerID:(int)customerID Status:(NSString *)status Currency:(NSString *)curr Page:(NSString *)page Success:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"CustomerID":@(customerID),@"AAAMethodName":@"SigningList",
                           @"Status":status,@"Currency":curr,@"Page":page,@"PageSize":@"10"};
    NSLog(@"获取签约列表params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取签约列表： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
//            if ([data[@"data"]count]>0) {
                success(dataA);
//            }else{
//                failure(HTTP_REQUEST_FAILURE);
//                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
//            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}
#pragma mark -获取签约流程
+ (void)getSigningProcessforBookingID:(NSString *)bookingID Success:(void(^)(NSArray *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"AAAMethodName":@"SigningProcess",@"BookingId":bookingID};
    NSLog(@"获取签约流程params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取签约流程： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {

            if ([data[@"data"]count]>0) {
                success(dataA);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -获取签约详情
+ (void)getSigningDetailforBookingID:(NSString *)bookingID Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"AAAMethodName":@"SigningDetail",@"BookingId":bookingID};
    NSLog(@"获取签约详情params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取签约详情： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {

            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 更新签约状态
+ (void)updateSigningStatusforBookingID:(NSString *)bookingID SignName:(NSString *)signName Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"AAAMethodName":@"ModifyStepStatus",
                           @"BookingId":bookingID,
                           @"StepName":signName};
    NSLog(@"更新签约状态params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        
        NSLog(@"更新签约状态： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 获取电子签名约定书
+ (void)getSignatureAgreementforBookingID:(NSString *)bookingID Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"AAAMethodName":@"SignatureAgreement",
                           @"BookingId":bookingID};
    NSLog(@"获取电子签名约定书params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取电子签名约定书： %@",[NSDictionary logDic:data]);
                NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                 success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 获取风险揭示书Risk 基金业务申请表FundBusiness 投资者匹配书Investor 份额确认书ShareConfirm
+ (void)getSignPDFWithMethoname:(NSString *)name BookingID:(NSString *)bookingID Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSDictionary *params=@{@"AAAMethodName":name,
                           @"BookingId":bookingID};
    NSLog(@"params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"responseObject:%@",[NSDictionary logDic:data]);
                NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 获取基金合同
+ (void)getSignFundContractWithBookingID:(NSString *)bookingID Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"FundContract",
                           @"BookingId":bookingID};
    NSLog(@"获取基金合同params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取基金合同： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 发送邮箱
+ (void)sendEmailWithBookingID:(NSString *)bookingID AndEmail:(NSString *)email Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"SendEmail",
                           @"BookingId":bookingID,@"Email":email};
    NSLog(@"发送邮箱params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"发送邮箱： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 获取首页轮播图
+ (void)getHomeTopImageDataSuccess:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"IndexImage"};
    NSLog(@"获取首页轮播图params： %@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取首页轮播图： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 获取签约列表数目
+ (void)getSigningNumWithCustomerId:(int)customerId CurrencyType:(NSString *)currency DataSuccess:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"SigningNum",@"CustomerId":@(customerId),@"Currency":currency};
    NSLog(@"params===%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"获取签约列表数目： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 查询客户的 实名认证,风险问卷调查,投资合格者认证
+ (void)getUserIDConfirmStatusForAccountPhone:(NSString *)userPhone Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"SearchThreeStatus",@"AccountPhone":userPhone};
    NSLog(@"查询状态params===%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"查询状态： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue] == 0 ) {
            
            if ([data[@"data"]count]>0) {
                success(dataA[0]);
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_LOADDATE_FAILURE];
            }
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}


#pragma mark - 更新客户的风险问卷调查QuestionnaireFinish,投资合格者认证InvestorConfirm
+ (void)updateUserIDConfirmStatusForMethod:(NSString *)methodName AccountPhone:(NSString *)userPhone Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":methodName,
                           @"AccountPhone":userPhone,@"status":@"完成"};
    NSLog(@"更新状态params===%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"更新状态： %@",[NSDictionary logDic:data]);
        success(data);
    
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark - 实名认证
+ (void)realNameConfirmForParams:(NSDictionary *)param Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    
    NSLog(@"实名认证params===%@",param);
    [manager POST:API_HOST1 parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"实名认证： %@",[NSDictionary logDic:data]);
        if ([data[@"state"] intValue] == 0 ) {
            success(data);
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}

#pragma mark -转为已读消息
+ (void)changeMyMessagesStatusforParams:(NSDictionary *)params Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure{
    //    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        //        [SVProgressHUD dismiss];
        NSLog(@"data==： %@",[NSDictionary logDic:data]);
        NSArray *dataA=data[@"data"];
        if ([data[@"state"] intValue]==0) {
            
            
                success(data);
          
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
    
}


#pragma mark - 获取基本信息
+ (void)getBaseInfoById:(NSString *)SubProductId Success:(void(^)(NSDictionary *data))success Failure:(void(^)(NSString *errorInfo))failure
{
    [HandleNetProduct show];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer    = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer.timeoutInterval = HTTP_REQUEST_TIMEOUT;
    NSDictionary *params=@{@"AAAMethodName":@"ProductBasicData",
                           @"SubProductId":SubProductId};
    NSLog(@"params===%@",params);
    [manager POST:API_HOST1 parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
        [SVProgressHUD dismiss];
        NSLog(@"赎回编辑显示： %@",[NSDictionary logDic:data]);
        if ([data[@"state"] intValue] == 0 ) {
            if ([data[@"data"] isKindOfClass:[NSArray class]]) {
                NSArray *list = data[@"data"];
                if (list.count > 0) {
                    success(list.firstObject);
                }
            }else{
                failure(HTTP_REQUEST_FAILURE);
                [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
            }
            
        }else{
            failure(data[@"msg"]);
            [[TKAlertCenter defaultCenter]postAlertWithMessage:data[@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(HTTP_REQUEST_FAILURE);
        [SVProgressHUD dismiss];
        [[TKAlertCenter defaultCenter]postAlertWithMessage:HTTP_REQUEST_FAILURE];
        
    }];
}


+(void)show{
    [SVProgressHUD showInfoWithStatus:@"loading..."];
}

+(void)showProgress:(float)gress{
    [SVProgressHUD showProgress:gress];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
}
@end
